<template>
  <view class="w100  pl-30 pr-30">
    <uni-card margin="0">
      <view class="inforClass">试卷信息:</view>
      <view class="rowsb rowsm mt-20 fs-26">
        <view class="ellipsis-text">
          <text class="fs-26 fw-600">试卷名称：</text>
          <text>{{ itemData.name }}</text>
        </view>
      </view>
      <view class="rowsb rowsm mt-10 fs-26">
        <view class="ellipsis-text">
          <text class="fs-26 fw-600">实践课程：</text>
          <text>
            <!-- {{ itemData.practiceType == 1 ? '劳动教育' : itemData.practiceType == 2 ? '职业素养' :
              itemData.practiceType
                == 3 ? '应急安全' : itemData.practiceType == 4 ? '思政实践' : '创新创业' }} -->
            {{ (practiceTypeList.find(v => v.id == itemData.practiceType) || {}).name }}
          </text>
        </view>
        <view class="ellipsis-text">
          <text class="fs-26 fw-600">积分上限：</text>
          <text>{{ itemData.score }}</text>
        </view>
      </view>
      <view class="rowsb rowsm mt-10 fs-26">
        <uni-tooltip :content="proxyNameList.join(',')" placement="top">
          <view class="ellipsis-text">
            <text class="fw-600 fs-26"> 学院：</text>
            <text>{{ proxyNameList.join(',') }}</text>
          </view>
        </uni-tooltip>
        <uni-tooltip :content="prozyNameList.join(',')" placement="top">
          <view class="ellipsis-text">
            <text class="fw-600 fs-26"> 专业：</text>
            <text> {{ prozyNameList.join(',') }}</text>
          </view>
        </uni-tooltip>
      </view>
      <view class="rowsb rowsm mt-10 fs-26">
        <uni-tooltip :content="probjNameList.join(',')" placement="top">
          <view class="ellipsis-text">
            <text class="fw-600 fs-26"> 班级：</text>
            <text>{{ probjNameList.join(',') }}</text>
          </view>
        </uni-tooltip>
        <uni-tooltip :content="itemData.faceNj" placement="top">
          <view class="ellipsis-text">
            <text class="fw-600 fs-26"> 年级：</text>
            <text>{{ itemData.faceNj || '全部' }}</text>
          </view>
        </uni-tooltip>
      </view>
      <view class="mt-10 fs-26">
        <text class="fw-600"> 考试时间：</text>
        <text>{{ itemData.startTime.slice(0, 10) }} ~ {{ itemData.endTime.slice(0, 10) }}</text>
      </view>
      <view class="rowsb rowsm mt-10 fs-26">
        <view class="ellipsis-text">
          <text class="fw-600"> 考试时长：</text>
          <text>{{ itemData.allTime }}分钟</text>
        </view>
      </view>
      <view class="fs-26 mt-10">
        本次知识问答单选题{{ itemData.selectNumber }}道、判断题{{ itemData.judgeNumber }}道、多选题{{ itemData.multipleNumber }}道，
        一共{{ itemData.selectNumber + itemData.judgeNumber + itemData.multipleNumber }}道题目。
      </view>
    </uni-card>

    <uni-card>
      <view class="inforClass">温馨提示:</view>
      <view>请考生认真作答，开始考试后不能中途退出。</view>
    </uni-card>
    <view class="w100 rowsa rowsm " style="bottom: 100rpx;">
      <view class="w-302 h-84 br-42 rowsc rowsm colfff mt-120"
        style="background: linear-gradient(to bottom,#4897FF,#4878FF);" @click="toPage">开始作答</view>
    </view>
  </view>
</template>
<script>
export default {
  data() {
    return {
      itemData: {},
      prozyNameList: [],
      proxyNameList: [],
      probjNameList: [],
      practiceTypeList: [],
    }
  },
  onLoad(e) {
    this.itemData = JSON.parse(e.item);
    this.getTypeCongfigList();
    this.getListProxy();
    this.getListProzy();
    this.getListProbj();
    uni.setNavigationBarTitle({
      // title:this.itemData.title 
      title: '开始做题'
    })
  },
  methods: {
    getTypeCongfigList() {
      this.$tools.axiosFromToken('GET', 'project/practice/type/config/listAll', {}, '加载中').then(res => {
        if (res.code != 200) return this.$tools.showtt(res.msg)
        this.practiceTypeList = res.rows;
      })
    },
    toPage() {
      // triviaAnswer
      this.$tools.goNext(`/pagesCopy/trivia/triviaAnswer?item=${JSON.stringify(this.itemData)}`)
    },
    // 查询学院
    getListProxy() {
      this.$tools.axiosFromToken('GET', 'project/proxy/listTotalAll', {}, '加载中').then(res => {
        if (res.code != 200) return this.$tools.showtt(res.msg)
        this.proxyNameList = [];
        res.rows.forEach(v => {
          this.itemData.faceXy.split(',').forEach(y => {
            if (v.id == y) {
              this.proxyNameList.push(v.name)
            }
          })
        })
      })
    },

    getListProzy() {
      this.$tools.axiosFromToken('GET', 'project/prozy/listTotalAll', {}, '加载中').then(res => {
        if (res.code != 200) return this.$tools.showtt(res.msg)
        // this.prozyList = res.rows;
        this.prozyNameList = [];
        res.rows.forEach(v => {
          this.itemData.faceZy.split(',').forEach(y => {
            if (v.id == y) {
              this.prozyNameList.push(v.name)
            }
          })
        })
      })
    },
    getListProbj() {
      this.$tools.axiosFromToken('GET', 'project/probj/listTotalAll', {}, '加载中').then(res => {
        if (res.code != 200) return this.$tools.showtt(res.msg)
        // this.probjList = res.rows;
        this.probjNameList = [];
        res.rows.forEach(v => {
          this.itemData.faceBj.split(',').forEach(y => {
            if (v.id == y) {
              this.probjNameList.push(v.name)
            }
          })
        })
      })
    },
  },
}
</script>
<style lang="scss">
page {
  background-color: #fff;
}

::v-deep .uni-card {
  margin-left: 5px !important;
  margin-right: 5px !important;
  overflow: visible;
}

::v-deep .uni-card__content {
  color: #000 !important;
}

::v-deep .uni-tooltip {
  width: 50%;
  display: flex;
}

::v-deep .uni-tooltip-popup {
  top: 20px;
  right: 0;
  text-align: justify;
  word-wrap: break-word;
}

.ellipsis-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: inline-block;
}

.inforClass {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  margin: 8px 0;
}

.inforClass::before {
  content: '';
  width: 5px;
  height: 20px;
  background-color: #007AFF;
  margin-right: 5px;
  display: inline-block;
}
</style>
